// components/memorialdayList/memorialdayList.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    dataItem: {
      type: Object,
      value: {}
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    closeDay:""
  },

  /**
   * 组件的方法列表
   */
  methods: {

  },
  lifetimes:{
    attached(){
      // 处理日期
      let targetDay = new Date(this.properties.dataItem.date)
      let month = targetDay.getMonth()
      let date = targetDay.getDate()

      let today = new Date()
      if((month > today.getMonth()) || (month == today.getMonth() && date > today.getDate())){
        targetDay.setFullYear(today.getFullYear())
      }
      else{
        targetDay.setFullYear(today.getFullYear()+1)
      }


      let closeDay
      if(targetDay.toDateString() == today.toDateString()){
        closeDay = 0
      }else{
        closeDay = Math.ceil(new Date(new Date(targetDay).getTime()-today.getTime()).getTime() / (1000*60*60*24))
      }

      this.setData({
        closeDay
      })
    }
  }
})
